﻿Public Class FormAssemblingRecord
    Private WithEvents UcDigitalKeyboard1 As ucDigitalKeyboard
    Dim objGjbMst As New clsGjbMst
    Dim objGjbInfo As New clsGJBinfo
    Private Sub FormAssemblingRecord_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        setDgvData()
    End Sub
    Public Sub setDgvData()
        Dim dt As DataTable = objGjbInfo.getGjbInfoListByStatus("0")
        dgv.AutoGenerateColumns = False
        dgv.DataSource = dt
    End Sub

    Private Sub dgv_SelectionChanged(sender As Object, e As EventArgs) Handles dgv.SelectionChanged
        If dgv.SelectedRows.Count > 0 Then
            Dim dtGjbMst As DataTable = objGjbMst.selectGjbByVal(dgv.SelectedRows(0).Cells("gjb_type").Value.ToString())
            'SpinEdit1.Value = dtGjbMst.Rows(0)("count")
            txt_num.Value = dgv.SelectedRows(0).Cells("layer_num").Value.ToString()
        End If
    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
        If dgv.SelectedRows.Count > 0 Then
            If txt_num.Value > 0 Then
                'If txt_num.Value <= SpinEdit1.Value Then
                Dim rtn As Integer = objGjbInfo.save(txt_num.Value.ToString(), dgv.SelectedRows(0).Cells("sys_id").Value.ToString())
                    If rtn = -2 Then
                        MsgBox("保存失败")
                    Else
                        MsgBox("保存成功")
                        setDgvData()
                    End If
                'Else
                '    MsgBox("装配数量需<=可装配数量")
                'End If
            Else
                MsgBox("装配数量需>0")
            End If
        End If
    End Sub

    Private Sub txt_num_MouseDown(sender As Object, e As MouseEventArgs) Handles txt_num.MouseDown
        UcDigitalKeyboard1 = New ucDigitalKeyboard
        If sender.MaskBox.Mask.EditMask = "d" Then
            UcDigitalKeyboard1.B_01 = False
        Else
            UcDigitalKeyboard1.B_01 = True
        End If

        If sender.GetType().Name.Equals("TextEdit") Then
            UcDigitalKeyboard1.B_02 = True
        Else
            UcDigitalKeyboard1.B_02 = False
        End If

        UcDigitalKeyboard1.Txt = sender

        Me.Controls.Add(UcDigitalKeyboard1)
        UcDigitalKeyboard1.Show()
        UcDigitalKeyboard1.BringToFront()
        UcDigitalKeyboard1.Focus()
    End Sub

End Class